<template>
  <div class="wfull">
    <a-empty v-if="obj===null"></a-empty>
    <a-form v-else :labelCol="{ span: 4 }" :wrapperCol="{ span: 20 }">
<#list allList as pro>
<#if pro.compType??>
<#if pro.compType=="int"||pro.compType=="double"||pro.compType=="text"||pro.compType=="textarea"||pro.compType=="date"||pro.compType=="datetime"||pro.compType=="time">
      <a-form-item label="${pro.columnVo.comment}">
        {{ obj.${pro.name} }}
      </a-form-item>
</#if>
<#if pro.compType=="checkbox"||pro.compType=="switch">
      <a-form-item label="${pro.columnVo.comment}">
        <a-tag v-if="obj.${pro.name}" color="blue">是</a-tag>
        <a-tag v-else color="red">否</a-tag>
      </a-form-item>
</#if>
<#if pro.compType=="tinymce">
      <a-form-item label="${pro.columnVo.comment}">
        <div v-html="obj.${pro.name}"></div>
      </a-form-item>
</#if>
<#if pro.compType=="dic">
      <a-form-item label="${pro.columnVo.comment}">
        <ZgDicHolder parentCode="${pro.genColumn.dicCode}" :code="obj.${pro.name}"></ZgDicHolder>
      </a-form-item>
</#if>
<#if pro.compType=="select"||pro.compType=="radio">
      <a-form-item label="${pro.columnVo.comment}">
        {{ getOptLabel(dic.${pro.name}Opts, obj.${pro.name}) }}
      </a-form-item>
</#if>
<#if pro.compType=="img">
      <a-form-item label="${pro.columnVo.comment}">
        <ZgImgHolder class="cpt" :src="obj.${pro.name}" isHead></ZgImgHolder>
      </a-form-item>
</#if>
<#if pro.compType=="attach">
      <a-form-item label="${pro.columnVo.comment}">
        <table class="table">
          <tr class="head">
            <td>图标</td>
            <td>文件名</td>
            <td>大小</td>
            <td>操作</td>
          </tr>
          <tr v-for="(f,i) in JSON.parse(obj.${pro.name})" :key="`${pro.name}_${r'${i}'}`">
            <td><ZgImgHolder :isBack="false" :src="f.icon" :width="32" :height="32"></ZgImgHolder></td>
            <td>{{ f.name }}</td>
            <td>{{ f.sizeStr }}</td>
            <td>
              <i class="fa fa-eye cpt mr10" title="查看"/>
              <i class="fa fa-download cpt" title="下载"/>
            </td>
          </tr>
        </table>
      </a-form-item>
</#if>
<#if pro.compType=="tags">
      <a-form-item label="${pro.columnVo.comment}">
        <a-tag v-for="(t,i) in JSON.parse(obj.${pro.name})" :key="`${pro.name}_${r'${i}'}`">{{ t }}</a-tag>
      </a-form-item>
</#if>
</#if>
</#list>
    </a-form>
  </div>
</template>
<script>
import { dic } from './dic'
export default {
  props: {
    obj: {
      type: Object,
      default: () => {
        return null
      }
    }
  },
  data () {
    return {
      dic
    }
  },
  methods: {
    getOptLabel (opts, value) {
      const arr = opts.filter(t => {
        return t.value === value
      })
      if (arr.length > 0) {
        return arr[0].label
      } else {
        return ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
